/* 
 * @(#) SelectAction.java  1.0  2004-4-21
 * 
 * Copyright 2003 by LongTop Corporation. 
 * All rights reserved. 
 * 
 * This software is the confidential and proprietary information of 
 * LongTop Corporation ("Confidential Information").  You 
 * shall not disclose such Confidential Information and shall use 
 * it only in accordance with the terms of the license agreement 
 * you entered into with LongTop. 
 */

package com.cnc.ssm.web;

import com.cnc.bas.util.Constants;
import com.cnc.bas.util.LTUtil;
import com.cnc.bas.web.SecureBaseDispatchAction;
import com.cnc.ssm.ISsmService;
import com.cnc.ssm.UserInfo;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @author du bf
 * @version 1.0 2005-3-24
 */
public class SelectAction extends SecureBaseDispatchAction {


    public ActionForward listEmployee(ActionMapping mapping,
                                      ActionForm form,
                                      HttpServletRequest request,
                                      HttpServletResponse response) throws Exception {
        UserInfo oper = (UserInfo) request.getSession().getAttribute(com.cnc.bas.util.Constants.USER_KEY);
        String keywords = request.getParameter("keywords");
        String multiRows = request.getParameter("multiRows");
        String listAll = request.getParameter("listAll");
        listAll = listAll == null ? "" : listAll.trim();
        listAll = listAll.equalsIgnoreCase("true") ? "true" : "false";
        keywords = keywords == null ? "" : "%" + keywords.trim() + "%";
        ISsmService ssmService = (ISsmService) this.getBean(Constants.BEAN_NAME_SSM);
//      liuwei修改过
        //String instCode = oper.getInstLevel().equals("3") ? oper.getInstCode() : "";

        HashMap hs = new HashMap();
//      liuwei修改过
       // hs.put("instCode", instCode);
        hs.put("keywords", keywords);
        List list = new ArrayList();
        if ((oper.getUserType().equals(Constants.PERSONUSER)) && listAll.equals("false")) {
            HashMap hm = new HashMap();
//          liuwei修改过
           // hm.put("EMPL_CODE", oper.getEmplCode().trim());
            hm.put("EMPL_NAME", oper.getUserName().trim());
            list.add(hm);
        } else {
            list = ssmService.listEmployee(hs);
        }
        LTUtil.setPageData(request, list);
        request.setAttribute("multiRows", (multiRows.equals("false") ? "radio" : "checkbox"));
        return mapping.findForward("listEmployee");
    }

}

